package app.server.project.cloud.core.http;


import app.server.project.cloud.core.exception.GlobalException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@Slf4j
@ControllerAdvice
public class GlobalRespAdvice  {

    @ExceptionHandler(GlobalException.class)
    @ResponseBody
    public RespModel doGlobalException(GlobalException e) {
        return RespModel.error(e.getCode());
    }


    @ExceptionHandler(Exception.class)
    public void doException(GlobalException e) {
        log.error("捕获到系统级别错误",e);
    }

}
